package se.webbzon.oschi01.item;

import se.webbzon.oschi01.metric.ClassNameMetric;
import se.webbzon.oschi01.metric.Metric;

public class ItemEntryMetric implements Metric<ItemEntry> {
	
	private final Metric<String> stringMetric;
	
	private final ClassNameMetric classNameMetric;
	
	public ItemEntryMetric(Metric<String> stringMetric) {
		this.stringMetric = stringMetric;
		classNameMetric = new ClassNameMetric(stringMetric);
	}

	@Override public double distance(ItemEntry lhs, ItemEntry rhs) {
		double s1 = classNameMetric.distance(lhs.getClassName(), rhs.getClassName());
		double s2 = stringMetric.distance(lhs.getUnlocalisedName(), rhs.getUnlocalisedName());
		double s3 = stringMetric.distance(lhs.getMod(), rhs.getMod());
		return s1 * 0.75  + (s2 + s3) * 0.25;
	}

}
